import { _decorator } from 'cc'
import { InputManager } from '../../Base/InputManager';
import { ENTITY_STATE_ENUM } from '../../Enum';
import { GroundState } from './GroundState';

const { ccclass, property } = _decorator;

@ccclass('RunState')
export class RunState extends GroundState {
    onEnter(): void {
        super.onEnter();
    }

    update(deltaTime: number): void {
        if(InputManager.Instance.moveDir.x === 0){
            this.fsm.transit(ENTITY_STATE_ENUM.IDLE)
        }
        super.update(deltaTime);
        
    }

    onExit(): void {
        super.onExit();
    }

    canTransit(to: ENTITY_STATE_ENUM): boolean  {
        if(to === this.id) return false;
        if(to === ENTITY_STATE_ENUM.JUMP) return true;
        if(to === ENTITY_STATE_ENUM.IDLE && this.fsm.lastOnGroundTime > 0) return true;
        return true;
    }
}


